
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Employee;
import cn.edu.scau.cmi.hombio.domain.MedicinePrice;
import cn.edu.scau.cmi.hombio.domain.MedicineStorage;
import cn.edu.scau.cmi.hombio.domain.MedicineStorageDetail;
import cn.edu.scau.cmi.hombio.domain.Supplier;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class MedicineStorageServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected MedicineStorageService service;

	/**
	 * Instantiates a new MedicineStorageServiceTest.
	 *
	 */
	public MedicineStorageServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Delete an existing Employee entity
	* 
	 */
	@Test
	public void deleteMedicineStorageEmployee() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineStorageEmployee 
		Integer medicinestorage_id = 0;
		Integer related_employee_id = 0;
		MedicineStorage response = null;
		response = service.deleteMedicineStorageEmployee(medicinestorage_id, related_employee_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineStorageEmployee
	}

	/**
	 * Operation Unit Test
	* Return all MedicineStorage entity
	* 
	 */
	@Test
	public void findAllMedicineStorages() {
		// TODO: JUnit - Populate test inputs for operation: findAllMedicineStorages 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<MedicineStorage> response = null;
		response = service.findAllMedicineStorages(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllMedicineStorages
	}

	/**
	 * Operation Unit Test
	* Load an existing MedicineStorage entity
	* 
	 */
	@Test
	public void loadMedicineStorages() {
		Set<MedicineStorage> response = null;
		response = service.loadMedicineStorages();
		// TODO: JUnit - Add assertions to test outputs of operation: loadMedicineStorages
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineStorageDetail entity
	* 
	 */
	@Test
	public void saveMedicineStorageMedicineStorageDetails() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineStorageMedicineStorageDetails 
		Integer id = 0;
		MedicineStorageDetail related_medicinestoragedetails = new cn.edu.scau.cmi.hombio.domain.MedicineStorageDetail();
		MedicineStorage response = null;
		response = service.saveMedicineStorageMedicineStorageDetails(id, related_medicinestoragedetails);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineStorageMedicineStorageDetails
	}

	/**
	 * Operation Unit Test
	* Delete an existing Supplier entity
	* 
	 */
	@Test
	public void deleteMedicineStorageSupplier() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineStorageSupplier 
		Integer medicinestorage_id_1 = 0;
		Integer related_supplier_id = 0;
		MedicineStorage response = null;
		response = service.deleteMedicineStorageSupplier(medicinestorage_id_1, related_supplier_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineStorageSupplier
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findMedicineStorageByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findMedicineStorageByPrimaryKey 
		Integer id_1 = 0;
		MedicineStorage response = null;
		response = service.findMedicineStorageByPrimaryKey(id_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findMedicineStorageByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Return a count of all MedicineStorage entity
	* 
	 */
	@Test
	public void countMedicineStorages() {
		Integer response = null;
		response = service.countMedicineStorages();
		// TODO: JUnit - Add assertions to test outputs of operation: countMedicineStorages
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicinePrice entity
	* 
	 */
	@Test
	public void deleteMedicineStorageMedicinePrices() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineStorageMedicinePrices 
		Integer medicinestorage_id_2 = 0;
		Integer related_medicineprices_id = 0;
		MedicineStorage response = null;
		response = service.deleteMedicineStorageMedicinePrices(medicinestorage_id_2, related_medicineprices_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineStorageMedicinePrices
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineStorage entity
	* 
	 */
	@Test
	public void deleteMedicineStorage() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineStorage 
		MedicineStorage medicinestorage = new cn.edu.scau.cmi.hombio.domain.MedicineStorage();
		service.deleteMedicineStorage(medicinestorage);
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicinePrice entity
	* 
	 */
	@Test
	public void saveMedicineStorageMedicinePrices() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineStorageMedicinePrices 
		Integer id_2 = 0;
		MedicinePrice related_medicineprices = new cn.edu.scau.cmi.hombio.domain.MedicinePrice();
		MedicineStorage response = null;
		response = service.saveMedicineStorageMedicinePrices(id_2, related_medicineprices);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineStorageMedicinePrices
	}

	/**
	 * Operation Unit Test
	* Save an existing Employee entity
	* 
	 */
	@Test
	public void saveMedicineStorageEmployee() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineStorageEmployee 
		Integer id_3 = 0;
		Employee related_employee = new cn.edu.scau.cmi.hombio.domain.Employee();
		MedicineStorage response = null;
		response = service.saveMedicineStorageEmployee(id_3, related_employee);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineStorageEmployee
	}

	/**
	 * Operation Unit Test
	* Save an existing Supplier entity
	* 
	 */
	@Test
	public void saveMedicineStorageSupplier() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineStorageSupplier 
		Integer id_4 = 0;
		Supplier related_supplier = new cn.edu.scau.cmi.hombio.domain.Supplier();
		MedicineStorage response = null;
		response = service.saveMedicineStorageSupplier(id_4, related_supplier);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineStorageSupplier
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineStorage entity
	* 
	 */
	@Test
	public void saveMedicineStorage() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineStorage 
		MedicineStorage medicinestorage_1 = new cn.edu.scau.cmi.hombio.domain.MedicineStorage();
		service.saveMedicineStorage(medicinestorage_1);
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineStorageDetail entity
	* 
	 */
	@Test
	public void deleteMedicineStorageMedicineStorageDetails() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineStorageMedicineStorageDetails 
		Integer medicinestorage_id_3 = 0;
		Integer related_medicinestoragedetails_id = 0;
		MedicineStorage response = null;
		response = service.deleteMedicineStorageMedicineStorageDetails(medicinestorage_id_3, related_medicinestoragedetails_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineStorageMedicineStorageDetails
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
